
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>编写高质量可维护的代码：优雅命名 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="编写高质量可维护的代码：数据建模.html" />
    
    
    <link rel="prev" href="编写高质量可维护的代码：优化逻辑判断.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >编写高质量可维护的代码：优雅命名</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;"><b>1. </b>&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;</a></li><ul><li><span class="title-icon "></span><a href="#&#x524D;&#x8A00;"><b>1.1. </b>&#x524D;&#x8A00;</a></li><li><span class="title-icon "></span><a href="#&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;"><b>1.2. </b>&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;</a></li><li><span class="title-icon "></span><a href="#&#x547D;&#x540D;&#x89C4;&#x5219;"><b>1.3. </b>&#x547D;&#x540D;&#x89C4;&#x5219;</a></li><ul><li><span class="title-icon "></span><a href="#&#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;"><b>1.3.1. </b>&#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#&#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;"><b>1.3.2. </b>&#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;</a></li><li><span class="title-icon "></span><a href="#&#x89C4;&#x8303;&#x7EA6;&#x675F;"><b>1.3.3. </b>&#x89C4;&#x8303;&#x7EA6;&#x675F;</a></li></ul><li><span class="title-icon "></span><a href="#&#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;"><b>1.4. </b>&#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;</a></li><ul><li><span class="title-icon "></span><a href="#&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;"><b>1.4.1. </b>&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;</a></li><li><span class="title-icon "></span><a href="#javascript"><b>1.4.2. </b>JavaScript</a></li><li><span class="title-icon "></span><a href="#css"><b>1.4.3. </b>css</a></li></ul></ul></ul></div><a href="#&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;"><a name="&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;" class="anchor-navigation-ex-anchor" href="#&#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x7F16;&#x5199;&#x9AD8;&#x8D28;&#x91CF;&#x53EF;&#x7EF4;&#x62A4;&#x7684;&#x4EE3;&#x7801;&#xFF1A;&#x4F18;&#x96C5;&#x547D;&#x540D;</h1>
<p>[TOC]</p>
<h2 id="&#x524D;&#x8A00;"><a name="&#x524D;&#x8A00;" class="anchor-navigation-ex-anchor" href="#&#x524D;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x524D;&#x8A00;</h2>
<p>&#x4FD7;&#x8BDD;&#x8BF4;&#x5F97;&#x597D;&#xFF0C;&#x4E07;&#x4E8B;&#x5F00;&#x5934;&#x96BE;&#x3002;&#x800C;&#x5BF9;&#x4E8E;&#x524D;&#x7AEF; coder &#x6765;&#x8BF4;&#xFF0C;&#x6BCF;&#x6B21;&#x65B0;&#x9879;&#x76EE;&#x3001;&#x65B0;&#x9700;&#x6C42;&#x6765;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x60F3;&#x5927;&#x5BB6;&#x6700;&#x82E6;&#x607C;&#x7684;&#x5F80;&#x5F80;&#x5C31;&#x662F;&#x5982;&#x4F55;&#x53BB;&#x547D;&#x540D;&#xFF0C;&#x65E0;&#x8BBA;&#x662F;&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x9875;&#x9762;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x79F0;&#x4EA6;&#x6216;&#x662F;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;&#x540D;&#x79F0;&#xFF0C;&#x5BF9;&#x4E8E;&#x6211;&#x6765;&#x8BF4;&#xFF0C;&#x4F46;&#x51E1;&#x540D;&#x5B57;&#x60F3;&#x597D;&#x4E86;&#x4EE5;&#x540E;&#xFF0C;&#x6211;&#x89C9;&#x5F97;&#x9700;&#x6C42;&#x5C31;&#x5DF2;&#x7ECF;&#x5199;&#x5B8C;&#x4E00;&#x534A;&#x4E86;&#x3002;</p>
<p>&#x5982;&#x4F55;&#x624D;&#x80FD;&#x66F4;&#x597D;&#xFF0C;&#x66F4;&#x4F18;&#x96C5;&#x7684;&#x53BB;&#x89E3;&#x51B3;&#x8FD9;&#x4E9B;&#x547D;&#x540D;&#x95EE;&#x9898;&#x5462;&#xFF1F;&#x5728;&#x8FD9;&#x4E4B;&#x524D;&#xFF0C;&#x5148;&#x968F;&#x6211;&#x770B;&#x4E00;&#x4E9B;&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;&#x793A;&#x4F8B;&#x5427;&#x3002;</p>
<h2 id="&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;"><a name="&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;" class="anchor-navigation-ex-anchor" href="#&#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x4E0D;&#x5408;&#x9002;&#x7684;&#x547D;&#x540D;</h2>
<p>&#x6211;&#x4EEC;&#x5148;&#x6765;&#x770B;&#x4E00;&#x4E9B;&#x4F8B;&#x5B50;&#xFF1A;</p>
<ul>
<li>&#x65E0;&#x610F;&#x4E49;&#x7684;&#xFF0C;&#x62BD;&#x8C61;&#x7684;&#xFF0C;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#xFF0C;&#x8C01;&#x90FD;&#x4E0D;&#x77E5;&#x9053;&#x4F60;&#x8FD9;&#x91CC;&#x7528;&#x7684;&#x547D;&#x540D;&#x6765;&#x6E90;&#x662F;&#x8C01;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> data;
<span class="hljs-keyword">const</span> info;
<span class="hljs-keyword">const</span> tool;
</code></pre>
<ul>
<li>&#x7B80;&#x79F0;&#xFF0C;&#x5355;&#x8BCD;&#x7684;&#x7B80;&#x79F0;&#x6216;&#x8005;&#x7F29;&#x5199;&#x5F88;&#x5BB9;&#x6613;&#x8BA9;&#x4EBA;&#x65E0;&#x6CD5;&#x786E;&#x5B9A;&#x5177;&#x4F53;&#x6307;&#x4EE3;&#x4EC0;&#x4E48;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> comp;
<span class="hljs-keyword">const</span> crt_date;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> components;
<span class="hljs-keyword">const</span> company;
<span class="hljs-keyword">const</span> current_date;
</code></pre>
<ul>
<li>&#x6570;&#x5B57;&#x6216;&#x8005;&#x5B57;&#x6BCD;&#x7ED3;&#x5C3E;&#x7684;&#x547D;&#x540D;&#xFF0C;&#x8BA9;&#x5176;&#x4ED6;&#x4EBA;&#x65E0;&#x6CD5;&#x83B7;&#x53D6;&#x8FD9;&#x4E9B;&#x4E4B;&#x95F4;&#x7684;&#x533A;&#x522B;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> button1;
<span class="hljs-keyword">const</span> button2;
<span class="hljs-keyword">const</span> info1;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> importButton;
<span class="hljs-keyword">const</span> userInfo;
</code></pre>
<ul>
<li>&#x5168;&#x5C40;&#x7684;&#x5730;&#x65B9;&#x4E0D;&#x8981;&#x7528;&#x524D;&#x7F6E;&#x6216;&#x540E;&#x7F6E;&#x4E0B;&#x5212;&#x7EBF;&#xFF0C;&#x524D;&#x7F6E;&#x4E0B;&#x5212;&#x7EBF;&#x901A;&#x5E38;&#x4EE3;&#x8868;&#x4E86;&#x79C1;&#x6709;&#x53D8;&#x91CF;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> _firstName_ = <span class="hljs-string">&apos;Zcy&apos;</span>;
<span class="hljs-keyword">const</span> firstName_ = <span class="hljs-string">&apos;Zcy&apos;</span>;
<span class="hljs-keyword">const</span> _firstName = <span class="hljs-string">&apos;Zcy&apos;</span>;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> firstName = <span class="hljs-string">&apos;Zcy&apos;</span>
</code></pre>
<h2 id="&#x547D;&#x540D;&#x89C4;&#x5219;"><a name="&#x547D;&#x540D;&#x89C4;&#x5219;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x540D;&#x89C4;&#x5219;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x547D;&#x540D;&#x89C4;&#x5219;</h2>
<p>&#x5982;&#x4F55;&#x8BA9;&#x547D;&#x540D;&#x66F4;&#x7B80;&#x5355;&#x5462;&#xFF0C;&#x53EA;&#x8981;&#x9075;&#x5FAA;&#x4E00;&#x4E9B;&#x89C4;&#x5219;&#x89C4;&#x8303;&#xFF0C;&#x603B;&#x80FD;&#x5C06;&#x590D;&#x6742;&#x7684;&#x4E8B;&#x60C5;&#x62C6;&#x5206;&#x5F00;&#x6765;&#xFF0C;&#x53D8;&#x6210;&#x4E00;&#x4EF6;&#x7B80;&#x5355;&#x7684;&#x4E8B;&#x60C5;&#x3002;</p>
<h3 id="&#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;"><a name="&#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;" class="anchor-navigation-ex-anchor" href="#&#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1. &#x76F4;&#x767D;&#x3001;&#x6709;&#x610F;&#x4E49;</h3>
<p>&#x60F3;&#x8981;&#x8BA9;&#x4F60;&#x7684;&#x547D;&#x540D;&#x7B80;&#x5355;&#x6613;&#x61C2;&#xFF0C;&#x6700;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x5F0F;&#x5C31;&#x662F;&#x76F4;&#x767D;&#x5E76;&#x4E14;&#x6709;&#x610F;&#x4E49;&#xFF0C;&#x76F4;&#x63A5;&#x4E86;&#x5F53;&#x7684;&#x5728;&#x547D;&#x540D;&#x4E2D;&#x4F53;&#x73B0;&#x51FA;&#x4F60;&#x8FD9;&#x4E2A;&#x547D;&#x540D;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x6216;&#x8005;&#x63CF;&#x8FF0;&#xFF0C;&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getInfo</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">formatList</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-keyword">const</span> data = [];

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getUserInfo</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">formatNewsList</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-keyword">const</span> articleData = [];
</code></pre>
<p>&#x5982;&#x679C;&#x5728;&#x9875;&#x9762;&#x4E2D;&#x5B9A;&#x4E49;&#x4E86;&#x4E0A;&#x9762;&#x8FD9;&#x6837;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x54EA;&#x79CD;&#x5199;&#x6CD5;&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x5728;&#x6CA1;&#x6709;&#x6CE8;&#x91CA;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5C31;&#x80FD;&#x5FEB;&#x901F;&#x4E86;&#x89E3;&#x539F;&#x4F5C;&#x8005;&#x7684;&#x4E66;&#x5199;&#x610F;&#x56FE;&#x5462;&#xFF1F;&#xFF08;&#x5F53;&#x7136;&#xFF0C;&#x4EE3;&#x7801;&#x4E2D;&#x8FD8;&#x662F;&#x9700;&#x8981;&#x4E00;&#x4E9B;&#x5FC5;&#x8981;&#x6CE8;&#x91CA;&#x7684;&#xFF09; &#x3002;</p>
<p>&#x6240;&#x4EE5;&#x5728;&#x547D;&#x540D;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x9700;&#x8981;&#x7684;&#x5C31;&#x662F;&#x76F4;&#x767D;&#x3001;&#x5B8C;&#x5907;&#x3001;&#x6709;&#x610F;&#x4E49;&#xFF0C;&#x8BA9;&#x522B;&#x4EBA;&#x901A;&#x8FC7;&#x547D;&#x540D;&#x5C31;&#x80FD;&#x4E86;&#x89E3;&#x5230;&#x8FD9;&#x4E2A;&#x540D;&#x79F0;&#xFF08;&#x65E0;&#x8BBA;&#x662F;&#x53D8;&#x91CF;&#x3001;&#x65B9;&#x6CD5;&#x6216;&#x8005;&#x662F;&#x6837;&#x5F0F;&#x540D;&#xFF09;&#x80CC;&#x540E;&#x7684;&#x7684;&#x542B;&#x4E49;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x547D;&#x540D;&#x5C31;&#x662F;&#x9AD8;&#x6548;&#x7684;&#x3001;&#x6613;&#x61C2;&#x7684;&#x3002;</p>
<h3 id="&#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;"><a name="&#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;" class="anchor-navigation-ex-anchor" href="#&#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.2. &#x9075;&#x4ECE;&#x60EF;&#x4F8B;&#x3001;&#x6807;&#x51C6;</h3>
<p>&#x4E60;&#x60EF;&#x4F7F;&#x7528;&#x4E1A;&#x754C;&#x4E60;&#x60EF;&#x7684;&#x547D;&#x540D;&#x6807;&#x8BC6;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x7EA6;&#x5B9A;&#x4FD7;&#x6210;&#x7684;&#x4E66;&#x5199;&#x4E60;&#x60EF;&#x3002;</p>
<ul>
<li>&#x7528; <code>id</code> &#x5F53;&#x505A;&#x6570;&#x636E;&#x6807;&#x8BC6;&#x547D;&#x540D;&#xFF0C;&#x800C;&#x4E0D;&#x662F; <code>identifier</code></li>
<li>&#x4F8B;&#x5982;&#x5E03;&#x5C14;&#x503C;&#x547D;&#x540D;&#x7C7B;&#x578B;&#xFF0C;&#x901A;&#x5E38;&#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x503C;&#x7C7B;&#x578B;&#xFF1A;&#x771F;&#xFF0C;&#x5047;&#xFF0C;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x6709;&#x4E00;&#x4E9B;&#x5E38;&#x7528;&#x7684;&#x547D;&#x540D;&#x65B9;&#x5F0F;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// &#x53EF;&#x89C1;&#x3001;&#x72B6;&#x6001;&#x7B49;&#xFF0C;&#x53EF;&#x7528; is+&#x52A8;&#x8BCD;/&#x5F62;&#x5BB9;&#x8BCD;&#x7684;&#x65B9;&#x5F0F;</span>
<span class="hljs-keyword">const</span> isVisible;
<span class="hljs-keyword">const</span> isLoading;

<span class="hljs-comment">// &#x914D;&#x7F6E;&#xFF0C;&#x9009;&#x9879;&#x7B49;&#x7C7B;&#x578B;&#xFF0C;&#x53EF;&#x4EE5;&#x7528; withXxx&#x3001;hasXxx &#x6765;&#x6807;&#x8BC6;&#x662F;&#x5426;&#x6709;&#x67D0;&#x4E2A;&#x5C5E;&#x6027;&#x7B49;,enableXxx &#x6765;&#x8868;&#x793A;&#x662F;&#x5426;&#x5F00;&#x542F;&#x914D;&#x7F6E;</span>
<span class="hljs-keyword">const</span> withTab;
<span class="hljs-keyword">const</span> hasPlan;
<span class="hljs-keyword">const</span> enableFilter;
</code></pre>
<ul>
<li>&#x4F8B;&#x5982;&#x65B9;&#x6CD5;&#x547D;&#x540D;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x52A8;&#x8BCD; + &#x540D;&#x6B21;&#x7C7B;&#x7684;&#x7EC4;&#x5408;&#x547D;&#x540D;&#x65B9;&#x5F0F;&#xFF0C;&#x64CD;&#x4F5C;&#x7C7B;&#x65B9;&#x6CD5; fetchXxx&#xFF0C;getXxx&#xFF0C;&#x5F53;&#x9700;&#x8981;&#x6839;&#x636E;&#x67D0;&#x4E9B;&#x5C5E;&#x6027;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x65F6;&#x53EF;&#x7528; &#xFF0C;getXxxByYxx &#x8FD9;&#x7C7B;&#x7684;&#x547D;&#x540D;&#xFF0C;&#x5220;&#x9664;&#x7C7B;&#x65B9;&#x6CD5; deleteXxx&#xFF0C;&#x683C;&#x5F0F;&#x5316;&#x6570;&#x636E; formatXxx</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// &#x6570;&#x636E;&#x83B7;&#x53D6;&#x65B9;&#x6CD5;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getUserInfo</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchSearchList</span>(<span class="hljs-params"></span>)</span>{};

<span class="hljs-comment">// &#x9700;&#x8981;&#x6839;&#x636E;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#x53BB;&#x83B7;&#x53D6;&#x6570;&#x636E;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getGoodsById</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">queryUserByName</span>(<span class="hljs-params"></span>)</span>{};

<span class="hljs-comment">// &#x5220;&#x9664;&#x6570;&#x636E;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deleteUser</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">removeGoodsItem</span>(<span class="hljs-params"></span>)</span>{};

<span class="hljs-comment">// &#x683C;&#x5F0F;&#x5316;&#x6570;&#x636E;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">formatDate</span>(<span class="hljs-params"></span>)</span>{}&#xFF1B;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sortByDesc</span>(<span class="hljs-params"></span>)</span>{}
</code></pre>
<h3 id="&#x89C4;&#x8303;&#x7EA6;&#x675F;"><a name="&#x89C4;&#x8303;&#x7EA6;&#x675F;" class="anchor-navigation-ex-anchor" href="#&#x89C4;&#x8303;&#x7EA6;&#x675F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.3. &#x89C4;&#x8303;&#x7EA6;&#x675F;</h3>
<p>&#x56E2;&#x961F;&#x5982;&#x679C;&#x7528;&#x7EDF;&#x4E00;&#x7684;&#x547D;&#x540D;&#x89C4;&#x8303;&#xFF0C;&#x90A3;&#x5C31;&#x4E00;&#x5B9A;&#x8981;&#x9075;&#x5B88;&#xFF0C;&#x4F8B;&#x5982;&#x6587;&#x4EF6;&#x540D;&#x7684;&#x547D;&#x540D;&#x662F;&#x5927;&#x5199;&#x5B57;&#x6BCD;&#x5F00;&#x5934;&#x7684;&#x9A7C;&#x5CF0;&#x5199;&#x6CD5;&#xFF0C;&#x90A3;&#x4F60;&#x7684;&#x547D;&#x540D;&#x5C31;&#x4E0D;&#x80FD;&#x518D;&#x4FEE;&#x6539;&#x4E3A;&#x5176;&#x4ED6;&#x65B9;&#x5F0F;&#xFF0C;&#x5728;&#x89C4;&#x8303;&#x521B;&#x5EFA;&#x4E4B;&#x521D;&#x6216;&#x8005;&#x4FEE;&#x8BA2;&#x65F6;&#x53EF;&#x4EE5;&#x63D0;&#x51FA;&#x4FEE;&#x6539;&#x610F;&#x89C1;&#x5E76;&#x8FDB;&#x884C;&#x8BA8;&#x8BBA;&#xFF0C;&#x4F46;&#x5982;&#x679C;&#x5DF2;&#x7ECF;&#x786E;&#x7ACB;&#x7684;&#xFF0C;&#x5C31;&#x4E0D;&#x8981;&#x518D;&#x3002;&#x53BB;&#x81EA;&#x7531;&#x7684;&#x7834;&#x574F;&#x89C4;&#x8303;&#x3002;</p>
<p>&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E00;&#x4E9B;&#x8F85;&#x52A9;&#x624B;&#x6BB5;&#x5E2E;&#x52A9;&#x7EA6;&#x675F;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x547D;&#x540D;&#x6821;&#x9A8C;&#xFF0C;<strong>&#x4F8B;&#x5982;&#x5728; Eslint &#x914D;&#x7F6E;&#x4E2D;&#x52A0;&#x5165; <code>id-match</code> &#x6216;&#x8005; <code>camelcase</code>&#xFF0C;&#x524D;&#x8005;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;&#x6B63;&#x5219;&#x914D;&#x7F6E;&#x81EA;&#x5DF1;&#x9700;&#x8981;&#x7684;&#x547D;&#x540D;&#x89C4;&#x8303;&#xFF0C;&#x540E;&#x8005;&#x5219;&#x662F;&#x76F4;&#x63A5;&#x91C7;&#x7528;&#x4E86;&#x9A7C;&#x5CF0;&#x547D;&#x540D;&#x7684;&#x89C4;&#x8303;&#x7EA6;&#x675F; </strong>&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x4E5F;&#x4E3E;&#x4F8B;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;&#x5728; <code>VsCode</code> &#x4E2D;  <code>Eslint</code>  &#x7684;&#x4F7F;&#x7528;</p>
<ul>
<li>&#x9996;&#x9009;&#x7535;&#x8111;&#x5168;&#x5C40;&#x5B89;&#x88C5; eslint</li>
</ul>
<pre><code class="lang-nginx"><span class="hljs-attribute">npm</span> install eslint -g
</code></pre>
<ul>
<li><code>VsCode</code> &#x4E2D;&#x5B89;&#x88C5; <code>ESlint</code> &#x63D2;&#x4EF6;&#x5E76;&#x4E14;&#x542F;&#x7528;</li>
<li>&#x5728;&#x81EA;&#x5DF1;&#x9879;&#x76EE;&#x4E2D;&#xFF0C;&#x6267;&#x884C; <code>eslint --init</code> &#x547D;&#x4EE4;&#x6765;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#x7684; <code>.eslintrc.js</code> &#x6587;&#x4EF6;&#xFF0C;&#x4E4B;&#x540E;&#x53EF;&#x4EE5;&#x5728; <code>.eslintrc.js</code> &#x6587;&#x4EF6;&#x4E2D;&#x7684; <code>rules</code> &#x89C4;&#x5219;&#x6DFB;&#x52A0;&#x4E0A;&#x89C4;&#x8303;&#x7684;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x6765;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x89C4;&#x5219;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-built_in">module</span>.exports = {
    <span class="hljs-string">&quot;rules&quot;</span>: {
      <span class="hljs-string">&quot;id-match&quot;</span>: [<span class="hljs-string">&quot;error&quot;</span>, <span class="hljs-string">&quot;^[a-z]+([A-Z][a-z]+)*$&quot;</span>],
      <span class="hljs-string">&quot;camelcase&quot;</span>: [<span class="hljs-string">&quot;error&quot;</span>, {<span class="hljs-string">&quot;properties&quot;</span>: <span class="hljs-string">&quot;always&quot;</span>}]
    }
}
</code></pre>
<ul>
<li>&#x9879;&#x76EE;&#x4E2D;&#x5982;&#x679C;&#x78B0;&#x5230;&#x4E0D;&#x7B26;&#x5408;&#x89C4;&#x8303;&#x7684;&#x5C31;&#x4F1A;&#x76F4;&#x63A5;&#x62A5;&#x9519;&#x63D0;&#x793A;</li>
</ul>
<h2 id="&#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;"><a name="&#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x547D;&#x540D;&#x89C4;&#x8303;&#x63A8;&#x8350;</h2>
<p>&#x4E0A;&#x9762;&#x7B80;&#x5355;&#x4ECB;&#x7ECD;&#x4E86;&#x4E00;&#x4E9B;&#x547D;&#x540D;&#x7684;&#x89C4;&#x5219;&#xFF0C;&#x90A3;&#x4E48;&#x5177;&#x4F53;&#x5230;&#x5B9E;&#x9645;&#x64CD;&#x4F5C;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x53C8;&#x6709;&#x54EA;&#x4E9B;&#x8F83;&#x597D;&#x7684;&#x547D;&#x540D;&#x89C4;&#x8303;&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x5462;&#xFF1F;&#x4E0B;&#x9762;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;&#xFF0C;&#x4E5F;&#x7B80;&#x5355;&#x7ED9;&#x5927;&#x5BB6;&#x4ECB;&#x7ECD;&#x4E00;&#x4E9B;&#x7ECF;&#x5E38;&#x63A8;&#x8350;&#x4F7F;&#x7528;&#x7684;&#x547D;&#x540D;&#x89C4;&#x8303;&#x3002;</p>
<h3 id="&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;"><a name="&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;" class="anchor-navigation-ex-anchor" href="#&#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.1. &#x9879;&#x76EE;&#x540D;&#x79F0;&#x3001;&#x6587;&#x4EF6;&#x540D;&#x79F0;</h3>
<p>&#x9879;&#x76EE;&#x6216;&#x8005;&#x5355;&#x6587;&#x4EF6;&#x7684;&#x547D;&#x540D;&#x65B9;&#x9762;&#xFF0C;&#x5E38;&#x89C1;&#x89C4;&#x5219;&#xFF1A;</p>
<ol>
<li><code>kebab-case</code>&#xFF1A;&#x6A2A;&#x77ED;&#x7EBF;&#x547D;&#x540D;&#xFF0C;&#x4E5F;&#x53EB;&#x4E32;&#x5F0F;&#x547D;&#x540D;&#x6CD5;&#xFF0C;&#x5C0F;&#x5199;&#x5B57;&#x6BCD;&#x7684;&#x8BCD;&#x7EC4;&#xFF0C;&#x4E2D;&#x95F4;&#x52A0; <code>-</code>&#x62FC;&#x63A5;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x547D;&#x540D;&#x4FBF;&#x4E8E;&#x540C;&#x7C7B;&#x5185;&#x5BB9;&#x5FEB;&#x901F;&#x67E5;&#x627E;</li>
</ol>
<pre><code class="lang-js"><span class="hljs-comment">// good</span>
news-index;
news-list;
news-detail;
</code></pre>
<ol>
<li><code>camelcase</code>&#xFF1A;&#x5C0F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x5B57;&#x4EE5;&#x5C0F;&#x5199;&#x5B57;&#x6BCD;&#x5F00;&#x59CB;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x5355;&#x5B57;&#x7684;&#x9996;&#x5B57;&#x6BCD;&#x5927;&#x5199;</li>
</ol>
<pre><code class="lang-js"><span class="hljs-comment">// good</span>
newsIndex;
newsList;
newsDetail;
</code></pre>
<h3 id="javascript"><a name="javascript" class="anchor-navigation-ex-anchor" href="#javascript"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.2. JavaScript</h3>
<ul>
<li>&#x53D8;&#x91CF;&#xFF1A;&#x5E38;&#x7528;&#x5C0F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> userInfo;
<span class="hljs-keyword">const</span> userAddressList;
<span class="hljs-keyword">const</span> currentDate;
</code></pre>
<ul>
<li>&#x5168;&#x90E8;&#x4F7F;&#x7528;&#x5927;&#x5199;&#x5B57;&#x6BCD;&#xFF0C;&#x5355;&#x8BCD;&#x4E4B;&#x95F4;&#x91C7;&#x7528; <code>_</code> &#x5206;&#x5272;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// good </span>
<span class="hljs-keyword">const</span> ITEM_LIST;
<span class="hljs-keyword">const</span> PAGE_ITEM_LIST;
<span class="hljs-keyword">const</span> DEFAULT_CONFIG;
</code></pre>
<ul>
<li>&#x65B9;&#x6CD5;&#xFF1A;&#x5C0F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;&#xFF0C;&#x5E76;&#x4E14;&#x63A8;&#x8350;&#x547D;&#x540D;&#x65F6;&#x6DFB;&#x52A0;&#x4E00;&#x4E9B;&#x52A8;&#x8BCD;&#x7C7B;&#xFF0C;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x5FEB;&#x901F;&#x7406;&#x89E3;&#x65B9;&#x6CD5;&#x542B;&#x4E49;&#xFF0C;&#x4F8B;&#x5982;&#x4EE5; handle &#x5F00;&#x5934;&#xFF0C;&#x4E2D;&#x95F4; xxx &#x8868;&#x793A;&#x64CD;&#x4F5C;&#x5185;&#x5BB9;&#xFF0C;show &#x8868;&#x793A;&#x5177;&#x4F53;&#x64CD;&#x4F5C;&#xFF0C; <code>handlexxxxChange</code>&#xFF0C;<code>handlexxxxShow</code>&#xFF0C;&#x800C;&#x6BD4;&#x5982;&#x6570;&#x636E;&#x83B7;&#x53D6;&#x53EF;&#x4EE5;&#x7528; get&#xFF0C;fetch &#x8FD9;&#x7C7B;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// &#x5C0F;&#x9A7C;&#x5CF0;&#x547D;&#x540D;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getUserInfo</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addSuplierInfo</span>(<span class="hljs-params"></span>)</span>{};

<span class="hljs-comment">// &#x6DFB;&#x52A0;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;&#x7C7B;&#x7684;&#x8F85;&#x52A9;&#x547D;&#x540D;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleUserInfoChange</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleTitleClick</span>(<span class="hljs-params"></span>)</span>{};
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchPageData</span>(<span class="hljs-params"></span>)</span>{};
</code></pre>
<ul>
<li>&#x7C7B;&#x540D;&#xFF1A;&#x5927;&#x9A7C;&#x5CF0;&#x547D;&#x540D;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CommonLogo</span></span>;
<span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CartCenter</span></span>;
</code></pre>
<h3 id="css"><a name="css" class="anchor-navigation-ex-anchor" href="#css"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3. css</h3>
<h4 id="bem-&#x89C4;&#x8303;"><a name="bem-&#x89C4;&#x8303;" class="anchor-navigation-ex-anchor" href="#bem-&#x89C4;&#x8303;"><i class="fa fa-link" aria-hidden="true"></i></a>BEM &#x89C4;&#x8303;</h4>
<p><code>BEM</code> &#x662F;&#x4E00;&#x79CD;&#x547D;&#x540D; CSS &#x6837;&#x5F0F;&#x7684;&#x547D;&#x540D;&#x65B9;&#x6CD5;&#x548C;&#x89C4;&#x8303;&#xFF0C;&#x5168;&#x79F0; <code>Block</code>&#xFF08;&#x5757;&#xFF09;&#x3001; <code>Elemen</code>t&#xFF08;&#x5143;&#x7D20;&#xFF09;&#x3001;<code>Modifier</code>&#xFF08;&#x4FEE;&#x9970;&#x7B26;&#xFF09; &#xFF0C;&#x60F3;&#x5FC5;&#x5F88;&#x591A;&#x4EBA;&#x90FD;&#x6BD4;&#x8F83;&#x719F;&#x6089;&#x4E86;&#x3002;</p>
<pre><code class="lang-js">Block&#xFF1A;&#x4E00;&#x822C;&#x53EF;&#x4EE5;&#x770B;&#x505A;&#x662F;&#x72EC;&#x7ACB;&#x5177;&#x6709;&#x5B9E;&#x9645;&#x610F;&#x4E49;&#x7684;&#x6A21;&#x5757;&#x90E8;&#x5206;&#xFF0C;&#x4F8B;&#x5982; header,container,menu &#x7B49;
</code></pre>
<pre><code class="lang-js">Element&#xFF1A;&#x7EC4;&#x6210; Block &#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x6CA1;&#x6709;&#x5177;&#x4F53;&#x7684;&#x5B9E;&#x9645;&#x610F;&#x4E49;&#xFF0C;&#x4E00;&#x822C;&#x4E5F;&#x4E0D;&#x72EC;&#x7ACB;&#x4F7F;&#x7528;&#xFF0C;&#x4F8B;&#x5982; menu item&#xFF0C;list item&#xFF0C;header title &#x7B49;
</code></pre>
<pre><code class="lang-react">Modifier&#xFF1A;&#x4E00;&#x822C;&#x662F;&#x5757;&#x6216;&#x8005;&#x5143;&#x7D20;&#x7684;&#x4FEE;&#x9970;&#x72B6;&#x6001;&#x6216;&#x8005;&#x884C;&#x4E3A;&#xFF0C;&#x4F8B;&#x5982; disabled&#xFF0C;color&#xFF0C;checked &#x7B49;
</code></pre>
<p>&#x800C; <code>BEM</code> &#x7684;&#x5199;&#x6CD5;&#x4E00;&#x822C;&#x662F;<code>.block-name__element-name--modifier-name</code>&#xFF0C;&#x5176;&#x4E2D; <code>Block</code> &#x4E0E; <code>Element</code> &#x4E4B;&#x95F4;&#x8FDE;&#x63A5;&#x662F;&#x901A;&#x8FC7; <code>__</code> &#x53CC;&#x4E0B;&#x5212;&#x7EBF;&#xFF0C;<code>Block</code>&#xFF0C;<code>Element</code> &#x4E0E; <code>Modifier</code> &#x4E4B;&#x95F4;&#x662F;&#x901A;&#x8FC7; <code>--</code> &#x53CC;&#x4E2D;&#x5212;&#x7EBF;&#x8FDB;&#x884C;&#x8FDE;&#x63A5;&#xFF0C;&#x5F53;&#x4F7F;&#x7528;<code>less</code>&#x6216;&#x8005; <code>sass</code> &#x8BED;&#x6CD5;&#x7F16;&#x5199; <code>css</code> &#x65F6;&#xFF0C;&#x901A;&#x8FC7;&#x5D4C;&#x5957;&#x8BED;&#x6CD5;&#x4E5F;&#x80FD;&#x591F;&#x5F88;&#x7B80;&#x6D01;&#x7684;&#x4E66;&#x5199;&#x8FD9;&#x90E8;&#x5206;&#x6837;&#x5F0F;&#x3002;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;head&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;head__title&quot;</span>&gt;</span>
    &#x6807;&#x9898;
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;head__title--disabled&quot;</span>&gt;</span>
      &#x7F6E;&#x7070;&#x5185;&#x5BB9;
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<pre><code class="lang-less"><span class="hljs-selector-class">.head</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fff</span>;
  <span class="hljs-selector-tag">&amp;</span><span class="hljs-selector-tag">__title</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">14px</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#666</span>;
    <span class="hljs-selector-tag">&amp;</span><span class="hljs-selector-tag">--disabled</span>: {
        <span class="hljs-attribute">color</span>: <span class="hljs-number">#f00</span>; 
    }
  }
}
</code></pre>
<p><code>BEM</code> &#x547D;&#x540D;&#x89C4;&#x8303;&#x53EF;&#x4EE5;&#x8BA9;&#x6837;&#x5F0F;&#x7684;&#x547D;&#x540D;&#x66F4;&#x52A0;&#x6A21;&#x5757;&#x5316;&#xFF0C;&#x7EC4;&#x4EF6;&#x4E4B;&#x95F4;&#x7ED3;&#x6784;&#x72EC;&#x7ACB;&#xFF0C;&#x51CF;&#x5C11;&#x4E86;&#x547D;&#x540D;&#x4E4B;&#x95F4;&#x7684;&#x51B2;&#x7A81;&#xFF0C;&#x6709;&#x7740;&#x4E0D;&#x9519;&#x7684;&#x6613;&#x8BFB;&#x6027;&#x3001;&#x7EF4;&#x62A4;&#x6027;&#x7B49;&#x7B49;&#xFF0C;&#x4F46;&#x53EF;&#x80FD;&#x4F1A;&#x8BA9;&#x9879;&#x76EE;&#x4E2D;&#x7684;&#x6837;&#x5F0F;&#x547D;&#x7279;&#x522B;&#x7684;&#x957F;&#x3002;</p>
<h4 id="&#x5E38;&#x7528;-css-&#x6837;&#x5F0F;&#x540D;&#x79F0;"><a name="&#x5E38;&#x7528;-css-&#x6837;&#x5F0F;&#x540D;&#x79F0;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;-css-&#x6837;&#x5F0F;&#x540D;&#x79F0;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E38;&#x7528; CSS &#x6837;&#x5F0F;&#x540D;&#x79F0;</h4>
<p>&#x8FD9;&#x91CC;&#x5F15;&#x7528;&#x4E00;&#x4E0B;&#x6398;&#x91D1;&#x4F5C;&#x8005; <code>&#x51B7;&#x77F3;Boy</code> &#x7684; css &#x6837;&#x5F0F;&#x540D;&#x79F0;</p>
<p><strong>&#x5305;&#x88F9;&#x7C7B;&#xFF1A;</strong> container, wrapper, outer, inner, box, header, footer, main, content, aside, page, section, block</p>
<p><strong>&#x72B6;&#x6001;&#x7C7B;&#xFF1A;</strong> primary, secondary, success, danger, warning, info, error, Link, light, dark, disabled, active, checked, loading</p>
<p><strong>&#x5C3A;&#x5BF8;&#x7C7B;&#xFF1A;</strong> large, middle, small, bigger, smaller</p>
<p><strong>&#x7EC4;&#x4EF6;&#x7C7B;&#xFF1A;</strong> card, list, picture, carousel, swiper, menu, navs, badge, hint, modal, dialog</p>
<p><strong>&#x4F4D;&#x7F6E;&#x7C7B;&#xFF1A;</strong> first, last, current, prev, next, forward, back</p>
<p><strong>&#x6587;&#x672C;&#x7C7B;&#xFF1A;</strong> title, desc, content, date, author, category,label,tag</p>
<p><strong>&#x4EBA;&#x7269;&#x7C7B;&#xFF1A;</strong> avatar, name, age, post, intro </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2021-07-06 17:31:15
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="编写高质量可维护的代码：优化逻辑判断.html" class="navigation navigation-prev " aria-label="Previous page: 编写高质量可维护的代码：优化逻辑判断">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="编写高质量可维护的代码：数据建模.html" class="navigation navigation-next " aria-label="Next page: 编写高质量可维护的代码：数据建模">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"编写高质量可维护的代码：优雅命名","level":"4.21","depth":1,"next":{"title":"编写高质量可维护的代码：数据建模","level":"4.22","depth":1,"path":"javaScript/编写高质量可维护的代码：数据建模.md","ref":"javaScript/编写高质量可维护的代码：数据建模.md","articles":[]},"previous":{"title":"编写高质量可维护的代码：优化逻辑判断","level":"4.20","depth":1,"path":"javaScript/编写高质量可维护的代码：优化逻辑判断.md","ref":"javaScript/编写高质量可维护的代码：优化逻辑判断.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/编写高质量可维护的代码：优雅命名.md","mtime":"2021-07-06T09:31:15.734Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

